/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef PLCOLOR_VGA16_H
#define PLCOLOR_VGA16_H

#include <stddef.h>
using namespace std;

/**
 * 16 colors class
 */
class PLColorVGA16 {
public:
	/**
	 * The enumeration of the 16 colors for the color.
	 */
	enum Colors16 {
		/**
		 * Black
		 */
		Black       = 0,
		/**
		 * Blue
		 */
		Blue        = 1,
		/**
		 * Green
		 */
		Green       = 2,
		/**
		 * Cyan
		 */
		Cyan        = 3,
		/**
		 * Red
		 */
		Red         = 4,
		/**
		 * Magenta
		 */
		Magenta     = 5,
		/**
		 * Orange
		 */
		Orange      = 6,
		/**
		 * Light Grey
		 */
		LightGrey   = 7,
		/**
		 * Dark Grey
		 */
		DarkGrey    = 8,
		/**
		 * Light Blue
		 */
		LightBlue   = 9,
		/**
		 * Light Green
		 */
		LightGreen  = 10,
		/**
		 * Light Cyan
		 */
		LightCyan   = 11,
		/**
		 * Light Red
		 */
		LightRed    = 12,
		/**
		 * Light Magenta
		 */
		LightMagenta= 13,
		/**
		 * Yellow
		 */
		Yellow      = 14,
		/**
		 * White
		 */
		White       = 15
	};
public:
	/**
	 * Black
	 */
	static PLColorVGA16 black;
	/**
	 * Blue
	 */
	static PLColorVGA16 blue;
	/**
	 * Green
	 */
	static PLColorVGA16 green;
	/**
	 * Cyan
	 */
	static PLColorVGA16 cyan;
	/**
	 * Red
	 */
	static PLColorVGA16 red;
	/**
	 * Magenta
	 */
	static PLColorVGA16 magenta;
	/**
	 * Orange
	 */
	static PLColorVGA16 orange;
	/**
	 * Light Grey
	 */
	static PLColorVGA16 lightGrey;
	/**
	 * Dark Grey
	 */
	static PLColorVGA16 darkGrey;
	/**
	 * Light Blue
	 */
	static PLColorVGA16 lightBlue;
	/**
	 * Light Green
	 */
	static PLColorVGA16 lightGreen;
	/**
	 * Light Cyan
	 */
	static PLColorVGA16 lightCyan;
	/**
	 * Light Red
	 */
	static PLColorVGA16 lightRed;
	/**
	 * Light Magenta
	 */
	static PLColorVGA16 lightMagenta;
	/**
	 * Yellow
	 */
	static PLColorVGA16 yellow;
	/**
	 * White
	 */
	static PLColorVGA16 white;
public:
	/**
	 * Constructor.
	 */
	PLColorVGA16();
	/**
	 * Copy constructor.
	 *
	 * @param c The color to copy.
	 */
	PLColorVGA16(const PLColorVGA16 &c);
	/**
	 * Set a color.
	 *
	 * @param c The text color.
	 */
	PLColorVGA16(PLColorVGA16::Colors16 c);
	/**
	 * Set a color.
	 *
	 * @param c The text color
	 * @param bc The background color.
	 */
	PLColorVGA16(PLColorVGA16::Colors16 c, PLColorVGA16::Colors16 bc);
	/**
	 * Get the textcolor.
     *
	 * @return The textcolor.
	 */
	inline PLColorVGA16::Colors16 color();
	/**
	 * Set the text color
     *
	 * @param c The text color.
	 */
	inline void setColor(PLColorVGA16::Colors16 c);
	/**
	 * Set the colors.
     *
	 * @param c The text color.
	 * @param bc The background color.
	 */
	inline void setColor(PLColorVGA16::Colors16 c, PLColorVGA16::Colors16 bc);
	/**
	 * Get the background color.
     *
	 * @return The background color.
	 */
	inline PLColorVGA16::Colors16 backgroundColor();
	/**
	 * Set the background color.
     *
	 * @param c The background color.
	 */
	inline void setBackgroundColor(PLColorVGA16::Colors16 c);
	/**
	 * Convert the VGA 16 color to an color enum.
     *
	 * @return The color value
	 */
    operator PLColorVGA16::Colors16();
	/**
	 * Convert the VGA 16 color to an int with the VGA attributes.
     *
	 * @return The int value
	 */
    operator uint8_t();
private:
	PLColorVGA16::Colors16 m_color;
	PLColorVGA16::Colors16 m_backgroundColor;
};

PLColorVGA16::Colors16 PLColorVGA16::color() {
	return m_color;
}

void PLColorVGA16::setColor(PLColorVGA16::Colors16 c) {
	m_color = c;
}

void PLColorVGA16::setColor(PLColorVGA16::Colors16 c, PLColorVGA16::Colors16 bc) {
	m_color = c;
	m_backgroundColor = bc;
}

PLColorVGA16::Colors16 PLColorVGA16::backgroundColor() {
	return m_backgroundColor;
}

#endif
